Mirror.prototype = new Sprite ();

function Mirror (x,y,normalVect,id,path){
    //properies
    Sprite.apply (this);
    this.path = path;
    this.MirrorImage = null; 
    this.buttonMode = true;
    this.mouseChildren = false;
    this.angle =null;
    this.id = id;
    this.x = x;
    this.y = y;
    this.nVect = normalVect;
    this.clicked = false;
    //methods association
    this.init = MirrorInit;
    this.getEdges = getEdges;
}

function MirrorInit (){
    var baseNormal = new Point (0,1);
    if ((this.nVect.y > 0 && this.nVect.x < 0)||(this.nVect.y < 0 && this.nVect.x < 0)){
       this.angle =Geometry.vectorAngle(this.nVect,baseNormal );
    }
    else{
        this.angle =360-Geometry.vectorAngle(this.nVect,baseNormal ); 
    }
    this.MirrorImage =  Game._game.bitmaps[this.path+"mirror.png"];
    this.MirrorImage.x = -20;
    this.MirrorImage.y = -20;
    this.MirrorImage.mouseChildren = false;
    this.rotation = this.angle;
    this.addChild (this.MirrorImage);
}

function getEdges(){
    var rotBaseA = Geometry.rotate(new Point(-20,0), this.angle);
    var rotBaseB = Geometry.rotate(new Point(20,0), this.angle);
    var edge1 = Geometry.vectorAddition(new Point(this.x,this.y),rotBaseA);
    var edge2 = Geometry.vectorAddition(new Point(this.x,this.y),rotBaseB);
    var result = [edge1,edge2];
    return result;
}